package com.gaogao.java;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class CalendaerTestMath {
    public static void main(String args[]) throws ParseException {
        String writedate="2020-04-05";
        DateFormat df=new SimpleDateFormat("yyyy-MM-dd");
        Date date= df.parse(writedate);
        Calendar calendar=new GregorianCalendar();
        calendar.setTime(date);
        int day=calendar.get(Calendar.DAY_OF_MONTH);
        calendar.set(Calendar.DAY_OF_MONTH,1);
        System.out.println(calendar.get(Calendar.DAY_OF_WEEK));
        System.out.println("日\t"+"一\t"+"二\t"+"三\t"+"四\t"+"五\t"+"六\t");
          for (int i=1 ;i<=calendar.get(Calendar.DAY_OF_WEEK);i++){
              System.out.print("\t");
          }
         int days=calendar.getActualMaximum(Calendar.DATE);
        for (int i=1;i<=days;i++){
            if(day==calendar.get(Calendar.DAY_OF_MONTH)){
                System.out.print("*");
            }
            System.out.print(calendar.get(Calendar.DAY_OF_MONTH)+"\t");
            calendar.add(Calendar.DAY_OF_MONTH,1);
            if (calendar.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY){
                System.out.println();
            }
        }
    }
}
